#pragma once
#include <vector>
#include "../SGD Wrappers/SGD_Geometry.h"

class TileSystem;
class BaseObject;
class Camera;

class ObjectManager
{
public:

	ObjectManager();
	~ObjectManager();

	/*****************************************************/
	//Object Storage
	std::vector<BaseObject*>*	GetAllObjects();
	//void	AddObject			(BaseObject*, unsigned int bucket);
	void	AddObjectTable		(BaseObject*, unsigned int bucket);
	void	RemoveObject		(BaseObject* pObject);
	void	RemoveAll			(unsigned int bucket);
	void	RemoveAll			(void);
	void	Respawn				(unsigned int bucket);
	
	// Get
	TileSystem* GetTileSystem()	{ return m_tTile; }

	/*****************************************************/
	// Entity Upkeep:
	void	UpdateAll(float dt);
	void	RenderAll(void);
	void    UnLoadAll();
	void	CheckCollisions(BaseObject * pOther);
	int	CheckPointInCollision(SGD::Point point);
private:

	ObjectManager(const ObjectManager&)				= delete;
	ObjectManager& operator= (const ObjectManager&) = delete;

	/*************************************************************/
	typedef std::vector <BaseObject*>	ObjectVector;
	typedef std::vector< ObjectVector > ObjectTable;

	ObjectTable  m_tObjects;				// vector of vectors of BaseObject* (2D table)

	std::vector<BaseObject*>		m_pObjects;


	/*************************************************************/
	// members:
	bool			m_bIterating = false;		// read/write lock
	TileSystem*		m_tTile;


};